package action;

import Impl.MessageDaoImpl;
import entity.Message;

import javax.naming.InsufficientResourcesException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "DeleteMessage")
public class DeleteMessage extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("--------正在执行DeleteMessage-----------");
        MessageDaoImpl messageDao = new MessageDaoImpl();
        int id = Integer.parseInt(request.getParameter("id"));
        System.out.println(id);
        messageDao.delete(id);
        System.out.println("删除成功");
        request.getRequestDispatcher("/message.jhtml?method=send").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
}
